﻿using DMC.Core.Models.Dto;
using DMC.Core.Models.Queries;
using DMC.Core.Models.VO;
using DMC.Core.Services;
using Microsoft.AspNetCore.Mvc;
using MiniFox.Infrastructure;
using MiniFox.Platform.Applications.Web;
using MiniFox.Utility;
using MiniFox.Web.Filters;
using MiniFox.Web.Infrastructure;

namespace DMC.Web.Controllers
{
    [NoCache, ValidationFilter, Area(GlobalConstants.AREA_NAME)]
    public class ExcelExportController : AuthorizedController<IExcelExportService>
    {
        [HttpPost]
        public Response<ResultObject<IEnumerable<ExcelExportVo>>> Query([FromBody] PagedQueryObject<ExcelExportQuery> request)
        {
            var result = this.Component.Query(request);
            return result.CreateResponse();
        }

        [HttpGet]
        public Response<ExcelExportVo> Item([FromQuery] string name)
        {
            var item = this.Component.Item(name);
            return item.CreateResponse();
        }

        [HttpPost]
        public Response Remove([FromBody] string name)
        {
            this.Component.Remove(name);
            return new();
        }
        [HttpPost]
        public Response<ExcelExportVo> Create([FromBody] ExcelExportDto dto)
        {
            var item = this.Component.Create(dto);
            return item.CreateResponse();
        }
        [HttpPost]
        public Response<ExcelExportVo> Update([FromBody] ExcelExportDto dto)
        {
            var item = this.Component.Update(dto);
            return item.CreateResponse();
        }
    }
}
